//
//  PPContactsSegmentedViewController.m
//  pickpic
//
//  Created by Jinxiao on 8/27/16.
//  Copyright © 2016 MicroDream. All rights reserved.
//

#import "PPContactsSegmentedViewController.h"

#import "PPContactsFriendViewController.h"
#import "PPContactsMiaoViewController.h"

@interface PPContactsSegmentedViewController ()

@end

@implementation PPContactsSegmentedViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor colorWithRGBHex:0xf2f2f2];
    self.title = @"通讯录";
}

- (void)transitIndicatorView:(UIView *)indicatorView fromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex {
    if(toIndex == 0) {
        [MobClick event:@"146"];
        indicatorView.backgroundColor = [UIColor colorWithRGBHex:0xef532a];
    } else {
        [MobClick event:@"147"];
        indicatorView.backgroundColor = [UIColor colorWithRGBHex:0x400090];
    }
}

- (CGFloat)preferredIndicatorHeight {
    return 3;
}

- (CGFloat)preferredIndicatorWidth {
    return self.view.width/2;
}

- (UIColor *)preferredIndicatorBackgroundColor {
    return [UIColor colorWithRGBHex:0xcccccc];
}

- (NSArray <NSString *> *)preferredTitles {
    return @[@"朋友", @"妙人"];
}

- (NSArray <UIViewController *> *)preferredViewControllers {
    PPContactsFriendViewController *friendsViewController = [[PPContactsFriendViewController alloc] init];
    PPContactsMiaoViewController *miaoViewController = [[PPContactsMiaoViewController alloc] init];

    return @[friendsViewController, miaoViewController];
}

- (UIButton *)preferredSegmentedButtonAtIndex:(NSInteger)index {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.backgroundColor = [UIColor clearColor];
    button.adjustsImageWhenHighlighted = NO;
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    [button setTitle:[[self preferredTitles] objectAtIndex:index] forState:UIControlStateNormal];
    [button setTitleColor:[UIColor colorWithRGBHex:0x161616] forState:UIControlStateNormal];
    [button setTitleColor:[UIColor colorWithRGBHex:0x161616] forState:UIControlStateHighlighted|UIControlStateSelected];
    [button setTitleColor:[UIColor colorWithRGBHex:0x161616] forState:UIControlStateSelected];

    return button;
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

@end
